﻿CREATE TABLE [dbo].[BillOrder] (
    [Id]                    INT             IDENTITY (1, 1) NOT NULL,
    [OpenId]                NVARCHAR (50)   NOT NULL,
    [CardType]              NVARCHAR (50)   NULL,
    [CardNo]                NVARCHAR (50)   NULL,
    [ClinicNo]              NVARCHAR (50)   NULL,
    [PrescMoney]            DECIMAL (18, 2) NULL,
    [OrderDept]             NVARCHAR (50)   NULL,
    [OrderDate]             NVARCHAR (50)   NULL,
    [Remark]                NTEXT           NULL,
    [OrderStatus]           INT             NOT NULL,
    [PayState]              NVARCHAR (50)   NULL,
    [CreateTime]            DATETIME        NULL,
    [PayTime]               DATETIME        NULL,
    [FetchTime]             DATETIME        NULL,
    [RefundTime]            DATETIME        NULL,
    [NextCheckTime]         DATETIME        NULL,
    [OrderStatusOnSetCheck] INT             NULL,
    [CheckReserved]         NVARCHAR (50)   NULL,
    [WxTransactionId]       NVARCHAR (50)   NULL,
    [WxRefundId]            NVARCHAR (50)   NULL,
    [OrderNo]               NVARCHAR (50)   NULL,
    [YiBaoStatus]           INT             NULL,
    [YibaoMoney]            DECIMAL (18, 2) NULL,
    [YiBaoJydjh]            NVARCHAR (50)   NULL,
    [YiBaoIndiId]           NVARCHAR (50)   NULL,
    [PersonalMoney]         DECIMAL (18, 2) NULL,
	[AliPayType]			NVARCHAR(20) not null,
    [CardName] NVARCHAR(50) NULL, 
    [PrescriptionIds] NVARCHAR(500) NULL, 
    [SettleCode] NVARCHAR(50) NULL, 
    PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'主键，自增长', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'Id';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信OpenId', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OpenId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'卡类型: 0-诊疗卡1-健康卡 2-市民卡', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'CardType';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'患者信息卡卡号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'CardNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'就诊流水号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'ClinicNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'缴费单开单费用', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'PrescMoney';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'缴费单开单科室', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OrderDept';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'缴费单开单时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OrderDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'备注', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'Remark';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付状态：0未支付 1支付中 2支付成功 3支付失败 4退款中 5退款成功 6退款失败 7缴费中 8缴费成功 9缴费失败', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OrderStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付状态:0-未付款,1-已付款,2-退款中,3-已退款', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'PayState';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单创建时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'CreateTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付成功时间，支付成功后微信返回', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'PayTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'缴费成功时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'FetchTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'退款成功时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'RefundTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统下次检查时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'NextCheckTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'设置系统下次检查时间时的订单状态', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OrderStatusOnSetCheck';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统检查预留字段', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'CheckReserved';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信支付交易号，支付成功后微信返回', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'WxTransactionId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信支付退款单号，退款成功后微信返回', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'WxRefundId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'OrderNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'医保使用状态，null，0：未使用医保，1：使用了医保，2：取消了医保，3：取消医保失败，4：获取医保失败', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'YiBaoStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'医保费用', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'YibaoMoney';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'医保就医登记号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'YiBaoJydjh';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'个人医保号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'YiBaoIndiId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'自费费用', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'BillOrder', @level2type = N'COLUMN', @level2name = N'PersonalMoney';


GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'就诊人姓名',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'CardName'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'处方单号',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'PrescriptionIds'
GO
EXEC sp_addextendedproperty @name = N'MS_Description',
    @value = N'结算类型代码，自费1',
    @level0type = N'SCHEMA',
    @level0name = N'dbo',
    @level1type = N'TABLE',
    @level1name = N'BillOrder',
    @level2type = N'COLUMN',
    @level2name = N'SettleCode'